/*
 * SkillFrameBackend.java
 * Team qq 2011
 */
package com.google.code.timetrail.presenter;

import com.google.code.timetrail.backend.Control;

/**
 * This is the backend for the skill frame
 * 
 * @author Utkarsh
 * @version 1.1
 */
public class SkillFrameBackend {
	/**
	 * The game control
	 */
	private final Control myGameControl;

	/**
	 * Position two
	 */
	private static final int POSITION_TWO = 2;

	/**
	 * Position three
	 */
	private static final int POSITION_THREE = 3;

	/**
	 * Value VALUE_HUNDRED
	 */
	private static final int VALUE_HUNDRED = 100;

	/**
	 * Value VALUE_FIVE
	 */
	private static final int VALUE_FIVE = 5;

	/**
	 * The constructor for this class
	 * 
	 * @param gameControl
	 *            the control for the game
	 */
	public SkillFrameBackend(Control gameControl) {
		myGameControl = gameControl;
	}

	/**
	 * Returns the swim label
	 * 
	 * @return the swim label
	 */
	public String getSwimLabel() {
		return "Swimming";
	}

	/**
	 * Returns the fitness label
	 * 
	 * @return the fitness label
	 */
	public String getFitnessLabel() {
		return "Fitness";
	}

	/**
	 * Return the bargain label
	 * 
	 * @return the bargain label
	 */
	public String getBargainLabel() {
		return "Bargaining";
	}

	/**
	 * Returns the immunity label
	 * 
	 * @return immunity label
	 */
	public String getImmunityLabel() {
		return "Immunity";
	}

	/**
	 * Returns the min skill level
	 * 
	 * @return the min skill level
	 */
	public int getMinSkillLevel() {
		return 0;
	}

	/**
	 * Returns the max skill level
	 * 
	 * @return the max skill level
	 */
	public int getMaxSkillLevel() {
		return VALUE_HUNDRED;
	}

	/**
	 * Returns the swim skill
	 * 
	 * @return the swim skill
	 */
	public int getSwimSkill() {
		return myGameControl.getPlayer().getSkills()[0];
	}

	/**
	 * Returns the fitness skill
	 * 
	 * @return the fitness skill
	 */
	public int getFitnessSkill() {
		return myGameControl.getPlayer().getSkills()[1];
	}

	/**
	 * Returns the bargain skill
	 * 
	 * @return the bargain skill
	 */
	public int getBargainSkill() {
		return myGameControl.getPlayer().getSkills()[POSITION_TWO];
	}

	/**
	 * Returns the immunity skill
	 * 
	 * @return the immunity skill
	 */
	public int getImmunitySkill() {
		return myGameControl.getPlayer().getSkills()[POSITION_THREE];
	}

	/**
	 * Returns the back button text
	 * 
	 * @return the back button text
	 */
	public String getBackButtonText() {
		return "Back <<";
	}

	/**
	 * UPgrades the swimming
	 */
	public void upgradeSwimming() {
		final int[] skills = myGameControl.getPlayer().getSkills();
		skills[0] += VALUE_FIVE;
		if (skills[0] > VALUE_HUNDRED) {
			skills[0] = VALUE_HUNDRED;
		}
		myGameControl.getPlayer().setSkills(skills);

	}

	/**
	 * Upgrades the fitness
	 */
	public void upgradeFitness() {
		final int[] skills = myGameControl.getPlayer().getSkills();

		skills[1] += VALUE_FIVE;
		if (skills[1] > VALUE_HUNDRED) {
			skills[1] = VALUE_HUNDRED;
		}
		myGameControl.getPlayer().setSkills(skills);

	}

	/**
	 * Upgrades the bargaining
	 */
	public void upgradeBargaining() {
		final int[] skills = myGameControl.getPlayer().getSkills();

		skills[POSITION_TWO] += VALUE_FIVE;
		if (skills[POSITION_TWO] > VALUE_HUNDRED) {
			skills[POSITION_TWO] = VALUE_HUNDRED;
		}
		myGameControl.getPlayer().setSkills(skills);

	}

	/**
	 * Upgrades the immunity
	 */
	public void upgradeImmunity() {
		final int[] skills = myGameControl.getPlayer().getSkills();

		skills[POSITION_THREE] += VALUE_FIVE;
		if (skills[POSITION_THREE] > VALUE_HUNDRED) {
			skills[POSITION_THREE] = VALUE_HUNDRED;
		}
		myGameControl.getPlayer().setSkills(skills);
	}
	
	/**
	 * The name of the class
	 * 
	 * @return the name of the class
	 */
	@Override
	public String toString() {
		return "SkillFrameBackend";
	}
}
